// import React from 'react';
import { connect } from 'dva';
import { Router, Route, Switch, Redirect } from 'dva/router';
import { Component } from 'react';

const AuthRouter = ({ dispatch, isLoggedIn, component: Component, ...props }) => {

  // const isLoggedIn = () => {
  //   dispatch({
  //     type: 'user/login',
  //     payload: 1,
  //   });
  // };

  return <Route {...props} render = {
    () => {
      console.log(isLoggedIn);
      return (isLoggedIn ? <Component {...props}/> : <Redirect to={'/login'} />)}
  } />
}

export default connect(({ isLoggedIn }) => ({
  isLoggedIn
}))(AuthRouter);
